<template>
<div class="section">
	<div class="sectionTit">分析师推荐</div>
	<div class="sectionContent">
		<div v-if="analystArray" class="slider swiper-container swiper2" style="padding:10px 0 12px 0;">
			<div class="item2 swiper-wrapper">
				<ul v-for="(items, index) in analystArray" class="analysisDisplay swiper-slide" style="padding:0px;">
					<li v-for="(item, index) in items">
						<div class="displayDiv">
							<router-link :to="{ name: 'AnalystInfo', params: { id: item.id }}">
								<img class="pic" v-lazy="item.img"/>
							</router-link>
							<p class="name">{{ item.name }}</p>
							<a class="btn redBtn" href="#"><img class="btnIco" src="../assets/img/ghfoi@2x.png" alt="" />给TA投票</a>
							<div class="visitNumber clearfloat">
								<p class="l"><img class="ico" src="../assets/img/fens@2x.png" alt="" />{{ item.view }}</p>
								<p class="r"><img class="ico" src="../assets/img/jii@2x.png" alt="" />{{ item.votes}}</p>
							</div>
						</div>
					</li>
				</ul>
			</div>
			<div class="swiper-pagination pageStyle pagination2"></div>
		</div>
	</div>
</div>
</template>

<script>
	import axios from 'axios'
	export default {
  		name: 'analystRecommend',
		data() {
	      return {
	        analystArray: []
	      }
	   },
	   mounted(){
  			var _this = this;
			_this.init();
		},
		methods: {
			init(){
				var _this = this;
				var domain = _this.$store.state.domain;
				axios.get(domain+'recommend_analyst').then(function(res) {
					var resData = res.data.data;
					for(var i=0,len=resData.length;i<len;i+=3){
					   _this.analystArray.push(resData.slice(i,i+3));
					}
					console.log(_this.analystArray);
					_this.$nextTick(()=>{ 
						var swiper = new Swiper('.swiper2', {
						   	autoplay: {
					        delay: 3500
					      },
					      pagination: {
					        el: '.pagination2',
					        clickable: true,
					        renderBullet: function (index, className) {
					          return '<span class="' + className + '"></span>';
					        },
					      },
					  });
				   });
				}).catch(function(error) {
					console.log(error);
				});
				
				
			}
		}
	}
</script>